package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Department;
import cn.wolfcode.mapper.DepartmentMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IDepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Slf4j
@Service
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;
    @Override
@Transactional
    public void insert(Department dept) {
        departmentMapper.insert(dept);
    }
    @Transactional
    @Override
    public void update(Department dept) {
     departmentMapper.update(dept);
    }
    @Transactional
    @Override
    public void delete(Long id) {
departmentMapper.delete(id);
    }
    @Transactional
    @Override
    public Department selectOne(Long id) {

        return departmentMapper.selectForId(id);
    }
    @Transactional
    @Override
    public List<Department> selectList() {
        return departmentMapper.selectList();
    }
    @Transactional
    @Override
    public PageInfo<Department> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
            List<Department> list = departmentMapper.selectForList(qo);
            return new PageInfo(list);
        }
    }